<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/doc/src/q3valuestack.qdoc -->
<head>
  <title>Qt 4.3: Q3ValueStack Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">Q3ValueStack Class Reference<br /><sup><sup>[<a href="qt3support.html">Qt3Support</a> module]</sup></sup></h1>
<p>The Q3ValueStack class is a value-based template class that provides a stack. <a href="#details">More...</a></p>
<pre> #include &lt;Q3ValueStack&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html">Porting to Qt 4</a> for more information.</p>
<p>Inherits <a href="q3valuelist.html">Q3ValueList&lt;T&gt;</a>.</p>
<ul>
<li><a href="q3valuestack-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="q3valuestack.html#Q3ValueStack">Q3ValueStack</a></b> ()</li>
<li><div class="fn"/><b><a href="q3valuestack.html#dtor.Q3ValueStack">~Q3ValueStack</a></b> ()</li>
<li><div class="fn"/>T <b><a href="q3valuestack.html#pop">pop</a></b> ()</li>
<li><div class="fn"/>void <b><a href="q3valuestack.html#push">push</a></b> ( const T &amp; <i>d</i> )</li>
<li><div class="fn"/>T &amp; <b><a href="q3valuestack.html#top">top</a></b> ()</li>
<li><div class="fn"/>const T &amp; <b><a href="q3valuestack.html#top-2">top</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>24 public functions inherited from <a href="q3valuelist.html#public-functions">Q3ValueList</a></li>
<li><div class="fn"/>44 public functions inherited from <a href="qlinkedlist.html#public-functions">QLinkedList</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>1 static public member inherited from <a href="qlinkedlist.html#static-public-members">QLinkedList</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The Q3ValueStack class is a value-based template class that provides a stack.</p>
<p>Define a template instance Q3ValueStack&lt;X&gt; to create a stack of values that all have the class X.</p>
<p>Note that Q3ValueStack does not store pointers to the members of the stack; it holds a copy of every member. That is why these kinds of classes are called &quot;value based&quot;; <a href="q3ptrstack.html">Q3PtrStack</a>, <a href="q3ptrlist.html">Q3PtrList</a>, <a href="q3dict.html">Q3Dict</a>, etc., are &quot;pointer based&quot;.</p>
<p>A stack is a last in, first out (LIFO) structure. Items are added to the top of the stack with <a href="q3valuestack.html#push">push</a>() and retrieved from the top with <a href="q3valuestack.html#pop">pop</a>(). The <a href="q3valuestack.html#top">top</a>() function provides access to the topmost item without removing it.</p>
<p>Example:</p>
<pre> Q3ValueStack&lt;int&gt; stack;
 stack.push( 1 );
 stack.push( 2 );
 stack.push( 3 );
 while ( ! stack.isEmpty() )
     cout &lt;&lt; &quot;Item: &quot; &lt;&lt; stack.pop() &lt;&lt; endl;

<span class="comment"> //</span> Output:
<span class="comment"> //</span>      Item: 3
<span class="comment"> //</span>      Item: 2
<span class="comment"> //</span>      Item: 1</pre>
<p>Q3ValueStack is a specialized <a href="q3valuelist.html">Q3ValueList</a> provided for convenience. All of <a href="q3valuelist.html">Q3ValueList</a>'s functionality also applies to <a href="q3ptrstack.html">Q3PtrStack</a>, for example the facility to iterate over all elements using Q3ValueStack&lt;T&gt;::Iterator. See <a href="q3valuelistiterator.html">Q3ValueListIterator</a> for further details.</p>
<p>Some classes cannot be used within a Q3ValueStack, for example everything derived from <a href="qobject.html">QObject</a> and thus all classes that implement widgets. Only values can be used in a Q3ValueStack. To qualify as a value, the class must provide</p>
<ul>
<li>a copy constructor;</li>
<li>an assignment operator;</li>
<li>a default constructor, i.e&#x2e; a constructor that does not take any arguments.</li>
</ul>
<p>Note that C++ defaults to field-by-field assignment operators and copy constructors if no explicit version is supplied. In many cases this is sufficient.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="Q3ValueStack"></a>Q3ValueStack::Q3ValueStack ()</h3>
<p>Constructs an empty stack.</p>
<h3 class="fn"><a name="dtor.Q3ValueStack"></a>Q3ValueStack::~Q3ValueStack ()</h3>
<p>Destroys the stack. References to the values in the stack and all iterators of this stack become invalidated. Because <a href="q3valuestack.html">Q3ValueStack</a> is highly tuned for performance, you won't see warnings if you use invalid iterators because it is impossible for an iterator to check whether or not it is valid.</p>
<h3 class="fn"><a name="pop"></a>T Q3ValueStack::pop ()</h3>
<p>Removes the top item from the stack and returns it.</p>
<p>See also <a href="q3valuestack.html#top">top</a>() and <a href="q3valuestack.html#push">push</a>().</p>
<h3 class="fn"><a name="push"></a>void Q3ValueStack::push ( const T &amp; <i>d</i> )</h3>
<p>Adds element, <i>d</i>, to the top of the stack. Last in, first out.</p>
<p>This function is equivalent to <a href="q3valuelist.html#append">append</a>().</p>
<p>See also <a href="q3valuestack.html#pop">pop</a>() and <a href="q3valuestack.html#top">top</a>().</p>
<h3 class="fn"><a name="top"></a>T &amp; Q3ValueStack::top ()</h3>
<p>Returns a reference to the top item of the stack or the item referenced by <a href="qlinkedlist.html#end">end</a>() if no such item exists. Note that you must not change the value the <a href="qlinkedlist.html#end">end</a>() iterator points to.</p>
<p>This function is equivalent to <a href="qlinkedlist.html#last">last</a>().</p>
<p>See also <a href="q3valuestack.html#pop">pop</a>(), <a href="q3valuestack.html#push">push</a>(), and <a href="q3valuelist.html#fromLast">Q3ValueList::fromLast</a>().</p>
<h3 class="fn"><a name="top-2"></a>const T &amp; Q3ValueStack::top () const</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Returns a reference to the top item of the stack or the item referenced by <a href="qlinkedlist.html#end">end</a>() if no such item exists.</p>
<p>This function is equivalent to <a href="qlinkedlist.html#last">last</a>().</p>
<p>See also <a href="q3valuestack.html#pop">pop</a>(), <a href="q3valuestack.html#push">push</a>(), and <a href="q3valuelist.html#fromLast">Q3ValueList::fromLast</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
